package com.example.flower_shop.service;

import com.example.flower_shop.dto.ProductDTO;
import com.example.flower_shop.entity.Product;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

public interface ProductService {

        // 基础CRUD方法
        Page<Product> findAll(Pageable pageable);

        Optional<Product> findById(Long id);

        void deleteById(Long id);

        // 现有的方法
        Page<Product> findProducts(String keyword, Pageable pageable);

        Product getProduct(Long id);

        Product createProduct(ProductDTO productDTO);

        Product updateProduct(Long id, ProductDTO productDTO);

        Product updateProductStatus(Long id, Integer status);

        Product updateProductDisplay(Long id, ProductDTO productDTO);

        Page<Product> findCarouselProducts(Pageable pageable);

        Page<Product> findRecommendProducts(Pageable pageable);

        Page<Product> findHotProducts(Pageable pageable);

        Page<Product> findProductsByCategory(Long categoryId, Pageable pageable);

        Page<Product> findByCategoryId(Long categoryId, Pageable pageable);

        List<Product> findByNameAndStatus(String name, Integer status);

        Page<Product> findAvailableProducts(Pageable pageable);

        Page<Product> findAvailableProductsByCategory(Long categoryId, Pageable pageable);

        Product createProduct(Long categoryId, String name, String description,
                        BigDecimal price, Integer stock, String imageUrl);

        Product updateProduct(Long id, Long categoryId, String name, String description,
                        BigDecimal price, Integer stock, String imageUrl);

        Product updateStock(Long id, Integer stock);

        Product updateStatus(Long id, Integer status);

        boolean checkStock(Long id, Integer quantity);

        void deductStock(Long id, Integer quantity);

        List<Product> findCarouselProducts();

        Page<Product> findRecommendedProducts(Pageable pageable);

        Product updateDisplayProperties(Long id, Boolean isCarousel, Boolean isRecommended,
                        Boolean isHot, Integer carouselSort, Integer recommendSort);

        Product updateSalesCount(Long id, Integer increment);

        long count();

        Product getById(Long id);
}